package com.hrm.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import com.google.gson.Gson;
import com.hrm.dto.DepartDto;
import com.hrm.pojo.Depart;
import com.hrm.service.DepartService;

@Namespace("/manager")
public class DepartNameAction {

	private DepartService departService;
	
	
	@Action(value="depart")
	public String findallName() throws IOException{
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setCharacterEncoding("UTF-8");
		
		/*List<Depart> departs = departService.findDepartName();
		List<DepartDto> departDtos = new ArrayList<DepartDto>();
		for (Depart depart : departs) {
			DepartDto dto = new DepartDto();
			dto.setEnglishnames(depart.getEnglishnames());
			dto.setNames(depart.getNames());
			departDtos.add(dto);
		}
		
		PrintWriter out = response.getWriter();
		response.setContentType("application/json;charset=UTF-8");
		
		Gson gson = new Gson();
		String json = gson.toJson(departDtos);
		System.out.println(json);
		out.print(json);
		
		out.flush();
		out.close();*/
		return null;
	}

	@Autowired
	public void setDepartService(DepartService departService) {
		this.departService = departService;
	}
	
	
	
}
